Un coup d’oeil sur la situation des différentes professions…

# qq packages nécessaire à l'analyse
library(tidyverse)
library(rmarkdown)    # You need this library to run this template.
library(epuRate)      # Install with devtools: install_github("holtzy/epuRate", force=TRUE)
library(plotly)       # To transform a ggplot in an interactive graph
library(htmlwidgets)  # To save the interactive graph as an html file
library(hrbrthemes)   # To improve the appearance of the ggplot Graphic
library(ggrepel)      # A clean way to annotate the graphic without overlapping
library(DT)

1 Source


Source des données avec lien. Description des données. Chargement du jeu de données propre:

data <- read.csv("batypik.dms")

2 Graphique statique


Réalisation du graphique

p <- data %>% 
  ggplot(aes(x = m.previs, y = m.atypik, size=eff, color=as.factor(psl1) )) +
    geom_point(alpha=0.9) +
    ylab("exposition aux horaires atypiques") +
    xlab("score moyen d'imprévisibilité des horaires") + 
    guides(size=FALSE) +                                                        #suppression de la légende pour la taille des groupes pro
    labs(
      title="Horaires de travail pour chaque type de profession en France",
      subtitle="Le théatre d'une illusion",
      caption="Source: enquête SUMER | Réalisation: Antoine Rouillard-Pérain",
      colour="Catégorie") +
    geom_text_repel( data=data %>% filter(m.previs>90 | m.atypik>150), aes(label=psl)) +
    geom_abline() +
    theme_ipsum()

p

Sauvegarde au format png

png("FrenchWorkingTime.png", width=600, height=600)
p
dev.off()
## quartz_off_screen 
##                 2

3 Graphique dynamique


Ce graphique permet de:

# Ajoute une colonne avec le texte du tooltip
data$text <- paste("profession: ", data$psl,0, "\n", "effectif: ", round(data$eff,0), "\n", "score imprévisibilité: ", round(data$m.atypik,0), "\n", "score horaire atypique: ", round(data$m.previs,0), sep="")

# Redo the static version
p <- data %>% 
  ggplot(aes(x = m.previs, y = m.atypik, size=eff, color=as.factor(psl1), text=text )) +
    geom_point(alpha=0.9) +
    ylab("exposition aux horaires atypiques") +
    xlab("score moyen d'imprévisibilité des horaires") + 
    guides(size=FALSE) +                                                        #suppression de la légende pour la taille des groupes pro
    labs(
      title="Horaires de travail pour chaque type de profession en France",
      subtitle="Le théatre d'une illusion",
      caption="Source: enquête SUMER | Réalisation: Antoine Rouillard-Pérain",
      colour="Catégorie") +
    geom_abline() +
    theme_ipsum()

widg <- ggplotly(p, tooltip="text")
widg

Export de la figure en un format html:

saveWidget(widg, file = "FrenchWorkingTime.html", selfcontained = TRUE)

4 Tableau de données


Ce tableau permet de rechercher une profession en particulier

tmp <- data %>% 
  select(-text) %>%
  mutate( eff=round(eff,0), m.atypik=round(m.atypik,0), m.previs=round(m.previs,0) )
colnames(tmp) <- c("Catégorie", "Profession", "Effectif", "Score horaire atypique", "Score horaire imprévisible")
datatable( tmp, rownames = FALSE, filter="top", options = list(pageLength = 15, scrollX=T) )
 

A work by Yan Holtz

Yan.holtz.data@gmail.com